package Dao

func Getallfactory() (error, []Factory, int64) {
	var factorydate []Factory
	var total int64

	//page := factoryParam["page"].(int)
	//pagesize := factoryParam["limit"].(int)
	//serchText := factoryParam["searchText"].(string)
	err := Db.Table("factory").Order("factory_id").Count(&total).Find(&factorydate).Error
	return err, factorydate, total
}

func AddFactory(factory Factory) error{
	err := Db.Table("factory").Select("factory_id","factory_name","is_del").Create(&factory).Error
	return err
}

func UpdateFactory(factory Factory) error{
	err := Db.Table("factory").Where("factory_id = ?", factory.Factory_id).Updates(&factory).Error
	return err
}

func DeleteFactory(id string) error {
	var factory []Factory
	err := Db.Table("factory").Where("factory_id = ?", id).Delete(&factory).Error
	return err
}